package cn.stylefeng.guns.modular.shuheng.warpper;

import cn.stylefeng.guns.core.common.constant.Constants;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
import cn.stylefeng.guns.core.shiro.ShiroKit;
import cn.stylefeng.guns.core.shiro.ShiroUser;
import cn.stylefeng.roses.core.base.warpper.BaseControllerWrapper;
import cn.stylefeng.roses.core.util.ToolUtil;
import cn.stylefeng.roses.kernel.model.page.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;
import java.util.Map;

public class FilesWrapper extends BaseControllerWrapper {

    public FilesWrapper(Map<String, Object> single) {
        super(single);
    }

    public FilesWrapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    public FilesWrapper(Page<Map<String, Object>> page) {
        super(page);
    }

    public FilesWrapper(PageResult<Map<String, Object>> pageResult) {
        super(pageResult);
    }

    @Override
    protected void wrapTheMap(Map<String, Object> map) {
        if(map.get("file_id")!=null){
            map.put("doFlag","已完成");
        }else{
            map.put("doFlag","未完成");
        }
        if(map.get("status")!=null){
            map.put("statusName",(int)map.get("status")==0?"正常":"是");
        }
        if(map.get("city")!=null){
            map.put("cityName", ConstantFactory.me().getRegionNameById((Long) map.get("city")));
        }
        if(map.get("county")!=null){
            map.put("countyName", ConstantFactory.me().getRegionNameById((Long) map.get("county")));
        }
        ShiroUser user = ShiroKit.getUser();
        if(Constants.LEVEL_PROVINCE.equals(user.getUserLevel())){
            if(map.get("file_data_score_p")!=null){
                map.put("hasScore",true);
            }else{
                map.put("hasScore",false);
            }
        }else if(Constants.LEVEL_CITY.equals(user.getUserLevel())){
            if(map.get("file_data_score_c")!=null){
                map.put("hasScore",true);
            }else{
                map.put("hasScore",false);
            }
        }else {
            map.put("hasScore",false);
        }

        if(map.get("score_user")!=null){
            map.put("scoreUserName",ConstantFactory.me().getUserNameById((Long) map.get("score_user")));
        }
    }
}
